﻿@using Core.FrameWork.Models.Enum.Common
@using Core.FrameWork.Models.Models.System;
@using Masuit.Tools.Systems;
@model List<IGrouping<ClerkLevelType,Core.FrameWork.Models.Models.System.SysOrderRule>>;
@{
    ViewBag.Title = "价格配置";
    Layout = "~/Views/Shared/_LayoutInput.cshtml";
}
<style>
    .layui-form-item .layui-input-inline {
        width: 100px;
    }
    .layui-form-items
    {
        margin-bottom:15px;
        clear:both;
    }
</style>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>价格配置</title>
</head>
<body class="pear-container">
    <form class="layui-form" action="">
                <div class="mainBox">
        @{
            foreach (var sysOrderRule in Model)
            {
                <div class="layui-card">
                    <div class="layui-card-header">@sysOrderRule.Key.GetDisplay()订单价格</div>
                    @foreach (var moneyRule in sysOrderRule)
                    {
                         <label class="layui-form-label">@moneyRule.OrderTypeEnum.GetDisplay()</label>
                      
                        foreach (var item in moneyRule.SysOrderMoneyRule)
                        {
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">@item.OrderServiceTime.GetDisplay()</label>
                                <div class="layui-input-inline">
                                <input type="hidden" name="Id" Id="Id" value="@item.Id" >
                                    <input type="text" Id="Money" name="Money" placeholder="" value="@item.Money" class="layui-input">
                                </div>
                            </div>
                        }
                        <br />
                    }
                </div>
            }
        }
             </div>
        <div class="bottom">
            <div class="button-container">
                <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                        lay-filter="user-save">
                    <i class="layui-icon layui-icon-ok"></i>
                    提交
                </button>
                <button type="reset" class="pear-btn pear-btn-sm">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </div>
    </form>
</body>
</html>
    <script>
        layui.use(['form', 'jquery'], function() {
            let form = layui.form;
            let $ = layui.jquery;
            form.on('submit(user-save)', function(data) {
                 var form = $(this).parents('form');
            var result = [];
            form.find('div div div').each(function () {
                var thisItem = $(this);
                if(thisItem.hasClass('layui-form-item layui-inline'))
                {
               
                 
  result.push({
                    Id: thisItem.find('div').find("input:eq(0)").val(),
                    Money: thisItem.find('div').find('input:eq(1)').val()
                })
                }
              
            });

                $.ajax({
                    url: 'UpdateMoney',
                    data: JSON.stringify(result),
                    dataType: 'json',
                    contentType: 'application/json',
                    type: 'post',
                    success: function(result) {
                         if (result.Code == 200) {
                             layer.msg(result.Msg, {
                                icon: 1,
                                time: 1000
                            }, function() {
                                parent.layer.close(parent.layer.getFrameIndex(window
                                    .name)); //关闭当前页
                                parent.layui.table.reload("user-table");
                            });

                    }
                    else
                    {
                        layer.msg(result.Msg, {
                                icon: 2,
                                time: 1000
                            });
                    }
                    }
                })
                return false;
            });
        })
    </script>
